﻿<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title></title>
<link href="${root!}/lib/ligerUI/skins/Aqua/css/ligerui-all.css" rel="stylesheet" type="text/css" />
<link href="${root!}/lib/ligerUI/skins/ligerui-icons.css" rel="stylesheet" type="text/css" />
<script src="${root!}/lib/jquery/jquery-1.3.2.min.js" type="text/javascript"></script>
<script src="${root!}/lib/ligerUI/js/core/base.js" type="text/javascript"></script>
<script src="${root!}/lib/ligerUI/js/plugins/ligerToolBar.js" type="text/javascript"></script>
<script src="${root!}/lib/ligerUI/js/ligerui.all.js" type="text/javascript"></script>
<script src="${root!}/lib/ligerUI/js/plugins/ligerForm.js"></script>
<script src="${root!}/lib/ligerUI/js/plugins/ligerMenu.js" type="text/javascript"></script>
<script src="${root!}/lib/ligerUI/js/plugins/ligerTip.js" type="text/javascript"></script>
<script src="${root!}/lib/jquery-validation/jquery.validate.min.js"></script>
<script src="${root!}/lib/jquery-validation/jquery.metadata.js" type="text/javascript"></script>
<script src="${root!}/lib/jquery-validation/messages_cn.js" type="text/javascript"></script>
<script src="${root!}/lib/js/orders.js"></script>
<script> 
var groupicon = "${root!}/lib/ligerUI/skins/icons/communication.gif";
var orghome = '${root!}/lib/ligerUI/skins/icons/home.gif';
var customers = '${root!}/lib/ligerUI/skins/icons/customers.gif';
var communication = '${root!}/lib/ligerUI/skins/icons/communication.gif';
var g = null;
var f = null;
var s = null;
var t = null;
var o = null;
$(function ()
{
	/**  工具栏 */
	$("#toptoolbar").ligerToolBar({ items: [
		{text: '增加', click: f_CuisineNew, icon:'add'},		
		{ line:true },
		{ text: '修改', click: f_CuisineModify ,icon:'modify'},
		{ line:true },
		{ text: '删除', click: f_CuisineDel,icon:'delete'},
		{ line:true },
		{ text: '查询', click: f_Search,icon:'search2'}
		]});
	
	var status = [ {value : "1",text : "启用"}, {value : "0",text : "禁用"}];
	
	/**  页面布局 */
	$(function (){
		$("#layout1").ligerLayout({ leftWidth: 270});
	});
	
	
	/**菜系管理Grid*/
	g = $("#cuisineGrid").ligerGrid({
		columns: [
		  { display: '主键', name: 'ID',hide: 1} ,		  
		  { display: '菜系名', name: 'NAME',width: 150},
		  { display: '是否启用', name: 'STATUTS',width: 150,
			  render:function(rowdata, index, value){
				  if(rowdata.STATUS=='1')
					  return "启用";
				  else 
					  return rowdata.STATUS == '0'? '禁用':rowdata.STATUS;
			 }},
		  { display: '说明', name: 'INFO',width:400},
		  { display: '最后更新人', name: 'USERNAME', width: 150, hide: 1},
		  { display: '最后更新人ID', name: 'LAST_UPDATED_BY', width: 150},
		  { display: '最后更新时间', name: 'LAST_UPDATE_DATE', width: 200}
		], 		
		url: '${root!}/sys/cuisine/getCuisineJson', 
		pageSize: 20,
		width: '100%', 
		height: '100%',
		frozen: false,
		rownumbers: true,
		method:"post",
		parms:[{name:"pid",value:'0'}]
	}); 
	
	/**菜系查询 */
	s = $("#Search").ligerForm({
		 inputWidth: 190, labelWidth: 80, space: 50,
			 fields: [
			 { display: "菜系名", name: "NAME", newline: true, type: "text" , group: "查询条件",groupicon: groupicon},	 
			 { display: "是否启用", name: "STATUS", newline: true, type: "combobox",
					options:{
						data : status,
						valueField : 'value',
						textField : 'text'
					}	 
			 },
			 { display: "创建时间", name: "LAST_UPDATE_DATE", newline: true, type: "date"}
			 ]
	});
	$("#Search").hide();
	 
	 /**菜系新增Form*/
	f = $("#CuisineForm").ligerForm({
		 inputWidth: 150, labelWidth: 80, space: 50,validate:{},
			 fields: [
			 { name: "ID", type: "hidden" },
			 { display: "菜系名", name: "NAME", newline: true, type: "text" ,validate:{required:true},disabled:true, group: "菜系信息",groupicon: groupicon},
	 		 { display: "状态", name: "STATUS", newline: false, type: "combobox", validate:{required:true},
	 			options : {
					data : status,
					valueField : 'value',
					textField : 'text',
					value : "1"
				  }},
			 { display: "说明", name: "INFO", newline: true, type: "text",validate:{required:true}}]
		 });
	$("#CuisineForm").hide();
});


/** 菜系新增*/
function f_CuisineNew(){	
	var filtercontainer = $("#CuisineForm").width(530).height(200).hide();		
		$.ligerDialog.open({
			width: 560, height: 250,target: filtercontainer, isResize: true, top: 50,title:'新增菜系',
			buttons: [
			   { text: '确定', onclick: function (item, dialog) { if(f_CuisineSave()) dialog.hide(); } },
			   { text: '取消', onclick: function (item, dialog) { dialog.hide(); } }
			 ]
		});	
}

/** 菜系保存*/
function f_CuisineSave(){
	var success = false;
	var data = f.getData();
	if (f.valid()) {
		do_ajaxSubmit1('', 'CuisineForm', '${root!}/sys/cuisine/saveOrUpdate');
		CuisineClear();
		success = true;
	} else {
		f.showInvalid();
	}
	return success;
}

/**菜系修改*/
function f_CuisineModify(){
	var row = g.getSelectedRow();
	if (!row) {
		$.ligerDialog.success('温馨提示：请选择要修改的行。');
		return; 
	}
	var filtercontainer = $("#CuisineForm").width(530).height(200).hide();
		f.setData(row);//把选择的行数据放到form
		$.ligerDialog.open({
			width: 560, height: 250,target: filtercontainer, isResize: true, top: 50,title:'新增修改',
			buttons: [
			   { text: '确定', onclick: function (item, dialog) { if(f_CuisineSave()) dialog.hide(); } },
			   { text: '取消', onclick: function (item, dialog) { CuisineClear(); dialog.hide();} }
			 ]
		});	
}

/** 清除菜系数据*/
function CuisineClear(){
	var initData = {"ID":"","NAME":"","INFO":"","STATUS":"","LAST_UPDATED_BY":"","LAST_UPDATE_DATE":""};
	f.setData(initData);
}

/**菜系查询*/
function f_Search(){
	var filtercontainer = $("#Search").width(530).height(200).hide();
	$.ligerDialog.open({
		width: 560, height: 250,
		target: filtercontainer, isResize: true, top: 50,title:'用户查询',
		buttons: [
		   { text: '确定', onclick: function (item, dialog) { g.setOptions({newPage:1});loadData(); dialog.hide(); } },
		   { text: '取消', onclick: function (item, dialog) { cancel(); dialog.hide(); } }
		 ]
	});
}

/**菜系查询条件*/
function loadData(){
	var sdata = s.getData();
	g.set('parms', { where: $.ligerui.toJSON(sdata)});
	g.loadData();
	cancel();
}

/**清空查询条件*/
function cancel(){	
	var initData = {"NAME":"","STATUS":"","LAST_UPDATE_DATE":""};
	s.setData(initData);
}

/**菜系删除*/
function f_CuisineDel(){
	var row = g.getSelectedRow();
	if (!row) {
		$.ligerDialog.success('温馨提示：请选择要删除的行。');
		return; 
	}
	$.ligerDialog.confirm('确认是否删除？', function (yes){
		if(yes==true){
			do_ajaxSubmit('','${root!}/sys/cuisine/delete/'+row["ID"]);	
		};
    });
}

</script>
<style type="text/css"> 
	body{ padding:0px; margin:0; overflow:hidden;}
	#layout1{  width:100%;margin:0; padding:0;  }  
	.l-page-top{ height:80px; background:#f8f8f8; margin-bottom:3px;}
	.tree{
		width:270px;
		height:600px;
		margin: 0px;
		border: 1px solid #ccc;
		overflow: auto;}
</style>
</head>
<body>

<div id="layout1">
	<div position="center" title="菜系管理">
		<!--菜系管理工具栏-->
		<div id="toptoolbar"></div>
		<!--菜系管理datagrid-->
		<div id="cuisineGrid"></div>
	</div>
</div> 
<!--查询-->
<form id="Search"></form>
<!--菜系-->
<form id="CuisineForm"></form>
</body>
</html>
